package com.atde._05_behavioral_design_patterns.interpreter;


import java.util.HashMap;

/**
 * @BelongsProject: hsp_java_design_mode
 * @BelongsPackage: com.atde._05_behavioral_design_patterns.interpreter
 * @Author: Del
 * @CreateTime: 2025-06-30  08:57
 * @Description: 解释器模式：此类为变量的解释器
 * @Version: 1.0
 */
public class VarExpression extends  Expression{

    private String key;

    public VarExpression(String key) {
        this.key = key;
    }

    // interpreter 根据变量的名称，返回对应的值
    @Override
    public int interpret(HashMap<String, Integer> var) {
        return var.get(this.key);
    }
}
